import json
import os

# 获取脚本所在目录的绝对路径
script_dir = os.path.dirname(os.path.abspath(__file__))
json_path = os.path.join(script_dir, '..', 'data', 'all_packages.json')

# 读取 JSON 文件
with open(json_path, 'r', encoding='utf-8') as f:
    data = json.load(f)

# 为每个包添加 alias 属性
for package in data:
    if 'status' in package and 'alias' not in package:
        package['alias'] = 'openharmony_tpc_samples'

# 写回文件
with open(json_path, 'w', encoding='utf-8') as f:
    json.dump(data, f, indent=2, ensure_ascii=False)